package com.itheima.mapper;

import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {
    //原始分页查询的实现方式
    //@Select("select count(*) from emp")
    //public long count();
    //@Select("select emp.*,dept.name as deptName from emp left join dept on emp.dept_id = dept.id order by update_time limit #{start},#{pageSize} " )
    //public List<Emp> list(Integer start , Integer pageSize);

     List<Emp> list(EmpQueryParam  param);

    void delete(Integer[] ids);
    //主键返回
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into emp(username,name,gender,image,job,salary,entry_date,dept_id,phone,create_time,update_time) values(#{username},#{name},#{gender},#{image},#{job},#{entryDate},#{deptId},#{phone},#{createTime},#{updateTime})")
    void add(Emp emp);
    @Select("select * from emp where id=#{id}")
    Emp getInfo(Integer id);
    @Insert("update emp set username=#{username},name=#{name},gender=#{gender},image=#{image},job=#{job},salary=#{salary},entry_date=#{entryDate},dept_id=#{deptId},phone=#{phone},update_time=#{updateTime} where id=#{id}")
    void update(Emp emp);
    @MapKey("pos")
    List<Map<String,Object>> countEmpJobData();
    @MapKey("name")
    List<Map<String,Object>> countEmpGenderData();
    @Select("select id,name,username from emp where username=#{username} and password=#{password}")
    Emp selectByUsernameAndPassword(Emp emp);
    @MapKey("name")
    List<Map<String, Object>> countStudentCountData();

    List<Emp> findAll();
}
